﻿#region Namespace References

using System;
using System.ComponentModel;
using DynConDevCorp.OpenArch.SmartData.Interfaces;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.WinForms
{
    /// <summary>
    /// 
    /// </summary>
    public partial class BindingManagerComponent : Component
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="BindingManagerComponent"/> class.
        /// </summary>
        public BindingManagerComponent()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BindingManagerComponent"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public BindingManagerComponent(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        #endregion

        #region Public Instance Properties

        /// <summary>
        /// Gets or sets the bound entity.
        /// </summary>
        /// <value>The bound entity.</value>
        public ISmartEntity BoundEntity
        {
            get { return m_BoundEntity; }
            set
            {
                m_BoundEntity = value;
                InvokeBoundEntityChanged(new EventArgs());
            }
        }

        #endregion

        #region Private Instance Methods

        private void InvokeBoundEntityChanged(EventArgs e)
        {
            if (BoundEntityChanged != null)
            {
                BoundEntityChanged(this, e);
            }
        }

        #endregion

        #region Fields and Constants

        private ISmartEntity m_BoundEntity;

        #endregion

        #region All Other Members

        /// <summary>
        /// Occurs when [bound entity changed].
        /// </summary>
        public event EventHandler BoundEntityChanged;

        #endregion
    }
}